Next | Prev | Up | Top | Contents | Index

Making a CPU Nonpreemptive

After a CPU has been isolated, you can turn off the dispatching "tick" for that CPU (see "Tick Interrupts"). This eliminates the last source of overhead interrupts for that CPU. It also ends preemptive process scheduling for that CPU. This means that the process now running will continue to run until

Some effects of this change within the specified CPU include the following:

Normally an isolated CPU runs only a few, related, time-critical processes that have equal priorities, and that coordinate their use of the CPU through semaphores or locks. When this is the case, the loss of preemptive scheduling is outweighed by the benefit of removing the overhead and unpredictability of interrupts.

To make a CPU nonpreemptive you can use mpadmin. For example, to isolate CPU 3 and make it nonpreemptive, you can use

mpadmin -I 3 mpadmin -D 3

The equivalent operation from within a program uses sysmp() as shown in Example 6-12 (see the sysmp(2) reference page).

Example 6-12 : Making a CPU nonpreemptive

#include <sys/sysmp.h>
int stopTimeSlicingOn(int cpu)
{
   int ret = sysmp(MP_NONPREEMPTIVE,cpu);
   if (-1 == ret) perror("sysmp(MP_NONPREEMPTIVE)");
   return ret;
}
You reverse the operation with sysmp(MP_PREEMPTIVE) or with mpadmin -C.


Next | Prev | Up | Top | Contents | Index